<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // https://leetcode-cn.com/problems/pascals-triangle/submissions/
        // 比较简单，画个图就出来了
        var generate = function(numRows) {
            let result = [];
            for (let i = 0; i < numRows; i++) {
                let tmp = [];
                for (let j = 0; j <= i; j++) {
                    if (j === 0 || j === i) {
                        tmp[j] = 1;
                    } else {
                        tmp[j] = result[i - 1][j - 1] + result[i - 1][j];
                    }
                }
                result.push(tmp);
            }
            return result;
        };
        console.log(generate(5));
    </script>
</body>
</html>